package com.company.emallbackend.controller;

import com.company.emallbackend.common.Result;
import com.company.emallbackend.entity.Collect;
import com.company.emallbackend.service.ICollectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
* <p>
*  前端控制器
* </p>
*
* @author hanlijian
* @since 2023-01-13
*/
@RestController
@RequestMapping("/collect")
@Api(tags = "商品收藏管理")
public class CollectController {

    @Resource
    private ICollectService collectService;

    /**
     * 我的商品收藏列表
     * @return
     */
    @GetMapping("myCollectList")
    @ApiOperation("我的商品收藏列表")
    public Result myCollectList(){
        List<Collect> collectList=collectService.myCollectList();
        return Result.success(collectList);
    }

    /**
     * 收藏商品
     * @param productId
     * @return
     */
    @GetMapping("addCollectProduct")
    @ApiOperation("收藏商品")
    public Result addCollectProduct(@RequestParam Integer productId){
        collectService.addCollectProduct(productId);
        return Result.success("商品收藏成功");
    }

}
